package com.example.learn.hwod;

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Collectors;

public class _29约瑟夫环 {

    public static void main(String[] args) {

        boolean[] booleans = new boolean[5];
        for (boolean aBoolean : booleans) {
            System.out.println(aBoolean);
        }
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        if(m<=1||m>=100){
            System.out.println("ERROR");
            return;
        }
        ArrayDeque<Integer> deque = new ArrayDeque<>();
        for (int i = 1; i <= 100; i++) {
            deque.addLast(i);
        }
        int num =1;
        while (deque.size() >= m) {
            Integer id = deque.pollFirst();
            if (num==m) {
                num=1;
            }else{
                num++;
                deque.addLast(id);
            }
            }
        StringJoiner joiner = new StringJoiner(",");
        deque.stream().sorted().forEach(System.out::println);
    }



}
